package com.atomos.strategy.initialize.velocity
{
	import com.atomos.particle.Particle;
	import com.atomos.strategy.initialize.InitializeStrategy;
	import com.bourre.structures.Range;
	import com.atomos.utils.RandomUtils;

	public class ExplosionInitializer implements InitializeStrategy
	{
		protected var _oAngleRange : Range;
		protected var _nRadius : Number;
		protected var _nRandom : Number;
		
		public function ExplosionInitializer ( radius : Number, angle : Range = null, rand : Number = 0 )
		{
			_nRadius = isNaN( radius ) ? 0 : radius;
			_nRandom = isNaN( rand ) ? 0 : rand;
			_oAngleRange = angle ? angle : new Range( 0, Math.PI * 2 );
		}
		public function initialize(particle:Particle):void
		{
			var a : Number = RandomUtils.range( _oAngleRange );
			var rad : Number = _nRadius + RandomUtils.balance( _nRandom );
			
			particle.velocity.x = Math.sin( a ) * rad;
			particle.velocity.y = Math.cos( a ) * rad;
		}
		
	}
}